home *** CD-ROM | disk | FTP | other *** search
/ Dynamic HTML Construction Kit / Dynamic HTML Construction Kit.iso / earthlink / nscomm / java40.jar / java / awt / Font.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-11-03  |  2.7 KB  |  125 lines

  1. package java.awt;
  2.  
  3. import java.io.Serializable;
  4.  
  5. public class Font implements Serializable {
  6.    public static final int PLAIN = 0;
  7.    public static final int BOLD = 1;
  8.    public static final int ITALIC = 2;
  9.    private transient int pData;
  10.    private transient String family;
  11.    protected String name;
  12.    protected int style;
  13.    protected int size;
  14.  
  15.    public Font(String var1, int var2, int var3) {
  16.       SecurityManager.enablePrivilege("UniversalPropertyRead");
  17.       this.family = System.getProperty("awt.font." + var1.toLowerCase(), var1);
  18.       this.name = var1;
  19.       this.style = var2;
  20.       this.size = var3;
  21.    }
  22.  
  23.    public String getFamily() {
  24.       return this.family;
  25.    }
  26.  
  27.    public String getName() {
  28.       return this.name;
  29.    }
  30.  
  31.    public int getStyle() {
  32.       return this.style;
  33.    }
  34.  
  35.    public int getSize() {
  36.       return this.size;
  37.    }
  38.  
  39.    public boolean isPlain() {
  40.       return this.style == 0;
  41.    }
  42.  
  43.    public boolean isBold() {
  44.       return (this.style & 1) != 0;
  45.    }
  46.  
  47.    public boolean isItalic() {
  48.       return (this.style & 2) != 0;
  49.    }
  50.  
  51.    public void finalize() {
  52.       this.dispose();
  53.    }
  54.  
  55.    public synchronized native void dispose();
  56.  
  57.    public static Font getFont(String var0) {
  58.       return getFont(var0, (Font)null);
  59.    }
  60.  
  61.    public static Font getFont(String var0, Font var1) {
  62.       String var2;
  63.       try {
  64.          var2 = System.getProperty(var0);
  65.       } catch (Exception var8) {
  66.          var2 = null;
  67.       }
  68.  
  69.       if (var2 == null) {
  70.          return var1;
  71.       } else {
  72.          String var3 = var2;
  73.          int var4 = 12;
  74.          byte var5 = 0;
  75.          int var6 = var2.indexOf(45);
  76.          if (var6 >= 0) {
  77.             var3 = var2.substring(0, var6);
  78.             var2 = var2.substring(var6 + 1);
  79.             if ((var6 = var2.indexOf(45)) >= 0) {
  80.                if (var2.startsWith("bold-")) {
  81.                   var5 = 1;
  82.                } else if (var2.startsWith("italic-")) {
  83.                   var5 = 2;
  84.                } else if (var2.startsWith("bolditalic-")) {
  85.                   var5 = 3;
  86.                }
  87.  
  88.                var2 = var2.substring(var6 + 1);
  89.             }
  90.  
  91.             try {
  92.                var4 = Integer.valueOf(var2);
  93.             } catch (NumberFormatException var7) {
  94.             }
  95.          }
  96.  
  97.          return new Font(var3, var5, var4);
  98.       }
  99.    }
  100.  
  101.    public int hashCode() {
  102.       return this.name.hashCode() ^ this.style ^ this.size;
  103.    }
  104.  
  105.    public boolean equals(Object var1) {
  106.       if (var1 instanceof Font) {
  107.          Font var2 = (Font)var1;
  108.          return this.size == var2.size && this.style == var2.style && this.name.equals(var2.name);
  109.       } else {
  110.          return false;
  111.       }
  112.    }
  113.  
  114.    public String toString() {
  115.       String var1;
  116.       if (this.isBold()) {
  117.          var1 = this.isItalic() ? "bolditalic" : "bold";
  118.       } else {
  119.          var1 = this.isItalic() ? "italic" : "plain";
  120.       }
  121.  
  122.       return this.getClass().getName() + "[family=" + this.family + ",name=" + this.name + ",style=" + var1 + ",size=" + this.size + "]";
  123.    }
  124. }
  125.